<template>
  <v-card class="bus-student-card" variant="flat" elevation="0">
    <v-card-text class="pa-3">
      <div class="d-flex align-center mb-2">
        <v-avatar :color="avatarColor" size="40" class="me-3">
          <span class="text-white font-weight-bold">{{ student.name.charAt(0) }}</span>
        </v-avatar>
        
        <div class="flex-grow-1">
          <h4 class="text-subtitle-1 font-weight-bold mb-0">{{ student.name }}</h4>
          <p class="text-caption text-medium-emphasis mb-0">{{ student.student_no }}</p>
          <p class="text-caption text-medium-emphasis mb-0">{{ student.class_name }}</p>
        </div>
        
        <v-chip
          color="primary"
          size="small"
          variant="outlined"
        >
          校车学生
        </v-chip>
      </div>
      
      <!-- 状态信息 -->
      <div v-if="student.departure_time" class="d-flex align-center mb-2">
        <v-icon size="16" class="me-2 text-medium-emphasis">mdi-clock</v-icon>
        <span class="text-caption">离园时间: {{ student.departure_time }}</span>
      </div>
      
      <!-- 备注信息 -->
      <div v-if="student.notes" class="notes-section">
        <v-icon size="16" class="me-2 text-medium-emphasis">mdi-note-text</v-icon>
        <span class="text-caption">{{ student.notes }}</span>
      </div>
    </v-card-text>
  </v-card>
</template>

<script setup>
import { computed } from 'vue'

// 组件属性定义
const props = defineProps({
  student: {
    type: Object,
    required: true
  }
})

// 头像颜色计算
const avatarColor = computed(() => {
  const colors = ['primary', 'secondary', 'accent', 'info', 'success', 'warning']
  const index = props.student.name.charCodeAt(0) % colors.length
  return colors[index]
})
</script>

<style scoped>
/* 学生卡片基础样式 */
.bus-student-card {
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: none !important;
  border-radius: 12px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.bus-student-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

/* 备注样式 */
.notes-section {
  background: rgba(25, 118, 210, 0.05);
  border-radius: 4px;
  padding: 8px;
  display: flex;
  align-items: flex-start;
  border-left: 3px solid #1976d2;
  margin-top: 8px;
}

/* 响应式设计 */
@media (max-width: 600px) {
  .bus-student-card .v-card-text {
    padding: 12px !important;
  }
  
  .v-avatar {
    width: 32px !important;
    height: 32px !important;
  }
}

/* 动画效果 */
.bus-student-card {
  animation: slideInUp 0.4s ease-out;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 深色主题适配 */
.v-theme--dark .bus-student-card {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
}

.v-theme--dark .notes-section {
  background: rgba(25, 118, 210, 0.1);
}
</style>
